# 使用官方Go镜像作为基础镜像
# FROM golang:1.21-bullseye
# 使用阿里云镜像
FROM registry.cn-hangzhou.aliyuncs.com/golang:1.21-bullseye

# 设置工作目录
WORKDIR /app

# 创建默认的 air 配置
RUN echo '\
root = "."\
tmp_dir = "tmp"\
\
[build]\
cmd = "go build -o ./tmp/main ."\
bin = "./tmp/main"\
include_ext = ["go", "tpl", "tmpl", "html"]\
exclude_dir = ["assets", "tmp", "vendor"]\
' > /app/.air.toml

# 设置热重载工具
RUN go install github.com/cosmtrek/air@v1.44.0

# 暴露端口(如果你的应用需要的话)
EXPOSE 8080

# 启动命令
CMD ["air", "-c", ".air.toml"]